/*
 * PublicRRDTool.h
 *
 *  Created on: 2017-3-30
 *      Author: root
 */

#ifndef PUBLICRRDTOOL_H_
#define PUBLICRRDTOOL_H_
#include"PublicConfig.h"
#if USE_PUBLIC_RRD
#include<time.h>
#include<stdint.h>
time_t GetRRDFirstTime(const char*RRDName);
time_t GetRRDLastTime(const char*RRDName);
typedef struct _RRDDateInfo{
time_t start_tm;//开始时间
time_t end_tm;//结束时间
unsigned long step;//梯度
unsigned long steps;//总个数
unsigned long ds_cnt;//标签数
char **ds_namv;//标签名
double*data;//数据
}RRDDateInfo;
//start数据不使用，end时间往后推一
RRDDateInfo*GetRRDData(const char*RRDName,time_t start,time_t end);
void ShowRRDData(RRDDateInfo*RRDInfo);
void FreeRRDData(RRDDateInfo*RRDInfo);
int CreateRRDToolByData(const char*RRDName,RRDDateInfo*info);
//指定dts名,bits倍数
void GraphRRDData(const char*pngname,const char*rrdname,const char*dtsname,time_t start,time_t end,const char*title,int bits,int useavg);
//要求有traffic_in跟traffic_out
//rrd自带95
void GraphRRDDataFlow(const char*pngname,const char*rrdname,time_t start,time_t end,const char*title,int bits);
//只保留进跟出较大的95值
void GraphRRDDataFlowEx(const char*pngname,const char*rrdname,time_t start,time_t end,const char*title,int bits,int useavg);
int CreateEmptyRRDTool(const char*RRDName,const char*DS1Name,const char*DS2Name);
//带宽相关
//创建RRD数据库
int CreateTrafficRRDTool(const char*rrdname,time_t starttime);
int UpdateTrafficRRDTool(const char*rrdname,time_t timestamp,uint64_t ifHCInOctets,uint64_t ifHCOutOctets);
int GraphTrafficRRDTool(const char*pngname,const char*rrdname,time_t starttime,time_t endtime);
#endif
#endif /* PUBLICRRDTOOL_H_ */
